<?php
namespace  SmsSend;

use think\Exception;

class EncryptUtil
{
    /**
     * 密码加密
     * $userid：用户账号
     * $pwd：用户密码
     */
    public function encrypt_pwd($userid, $pwd)
    {
        try {
            $char = '00000000';//固定字符串
            $time = date('mdHis', time());//时间戳
            $pwd = md5($userid . $char . $pwd . $time);//拼接字符串进行加密
            return array('pwd' => $pwd, 'time' => $time);
        } catch (Exception $e) {
            print_r($e->getMessage());  //输出捕获的异常消息
        }
    }
    /**
     * 短信内容加密
     * $content：短信内容
     */
    public function encrypt_content($content)
    {
        try {
            return urlencode(iconv('UTF-8', 'GBK', $content));//短信内容转化为GBK格式再进行urlencode格式加密
        }catch (Exception $e) {
            print_r($e->getMessage());  //输出捕获的异常消息
        }
    }
}
?>